package com.app.business.show;

import com.alibaba.fastjson.JSON;
import com.app.business.model.*;
import com.app.business.service.*;
import com.app.system.jpa.PageBean;
import com.app.system.permission.service.DataDictService;
import com.app.system.utils.CollectionUtils;
import com.app.system.utils.ParamUtils;
import com.app.system.utils.dataType.DateUtils;
import com.app.system.utils.dataType.IntegerUtils;
import com.app.system.utils.dataType.StringUtils;
import com.app.system.utils.exception.Response;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 大屏公示（没有权限限制）
 * Created by ZYK on 2019/6/17.
 */
@Controller
@RequestMapping("/show/*")
@SuppressWarnings("all")
public class ShowController {
    @Autowired
    private ContractService contractService;
    @Autowired
    private ZsProjectService zsProjectService;
    @Autowired
    private AzProjectService azProjectService;
    @Autowired
    private DataDictService dataDictService;
    @Autowired
    private HouseService houseService;
    @Autowired
    private CarLotService carLotService;
    @Autowired
    private StorageRoomService storageRoomService;
    @Autowired
    private StatisticsService statisticsService;

    /**
     * 大屏主界面
     */
    @RequestMapping("tv")
    public void tv(ModelMap modelMap) {
    }
    /**
     * 大屏主界面
     */
    @RequestMapping("tv1")
    public void tv1(ModelMap modelMap) {
    }


    /**
     * 2024-东园-凤林花苑(二期)
     * 大屏主界面
     */
    @RequestMapping("tvFl")
    public void tvFl(ModelMap modelMap) {
    }

    /**
     * 2024-东园-锦溪花苑(二期)
     * 大屏主界面
     */
    @RequestMapping("tvJx")
    public void tvJx(ModelMap modelMap) {
    }

    /**
     * 2024-张坂-下宫安置区(二期)
     * 大屏主界面
     */
    @RequestMapping("tvXg")
    public void tvXg(ModelMap modelMap) {
    }

    /**
     * 2024-东园-玉泰新城
     * 大屏主界面
     */
    @RequestMapping("tvYt")
    public void tvYt(ModelMap modelMap) {
    }
    /**
     * 柱状图
     */
    @RequestMapping("houseZhuShow")
    public void houseZhuShow(ModelMap modelMap) {
    }

    /**
     * 柱状图
     */
    @RequestMapping("houseZhuShow2")
    public void houseZhuShow2(ModelMap modelMap) {
    }

    /**
     * 选房家庭公示
     */
    @RequestMapping("contractShowMain")
    public void contractShowMain(ModelMap modelMap) {
        Map<String, String> townMap = this.dataDictService.getMapByParentNameForValue_Name("乡镇");
        Map<String, List<ZsProject>> zsProjectMap = this.zsProjectService.getZsProjectMap();
        modelMap.addAttribute("townMap", townMap);
        modelMap.addAttribute("zsProjectMap", zsProjectMap);
    }

    /**
     * 得到某些征收项目下对应的安置项目
     *
     * @param request
     * @return
     */
    @RequestMapping("getAzProjectListByZsProjectIdStr")
    @ResponseBody
    public Response getAzProjectListByZsProjectIdStr(HttpServletRequest request) {
        String zsProjectIdStr = ParamUtils.getString(request, "zsProjectIdStr", "");
        List<AzProject> azProjectList = this.azProjectService.getAzProjectListByZsProjectIdStr(zsProjectIdStr);
        Response response = new Response();
        response.setData(azProjectList);
        response.setCode("0001");
        response.setMessage("数据加载成功!");
        return response;
    }

    /**
     * 选房家庭公示
     *
     * @param request
     * @param modelMap
     */
    @RequestMapping("contractShow")
    public void contractShow(HttpServletRequest request, ModelMap modelMap) {
        String zsProjectIdStr = ParamUtils.getString(request, "zsProjectIdStr", "");
        String azProjectIdStr = ParamUtils.getString(request, "azProjectIdStr", "");
        List<ZsProject> zsProjectList = this.zsProjectService.getZsProjectListByZsProjectIdStr(zsProjectIdStr);
        List<AzProject> azProjectList = this.azProjectService.getAzProjectListByAzProjectIdStr(azProjectIdStr);

        Map<String, AzProject> azProjectMap = this.azProjectService.getAzProjectMap();

        modelMap.addAttribute("zsProjectIdStr", zsProjectIdStr);
        modelMap.addAttribute("azProjectIdStr", azProjectIdStr);
        modelMap.addAttribute("zsProjectList", zsProjectList);
        modelMap.addAttribute("azProjectList", azProjectList);
        modelMap.addAttribute("azProjectMap", azProjectMap);

    }

    /**
     * 选房家庭公示
     *
     * @param request
     * @param modelMap
     */
    @RequestMapping("contractShowForBs")
    public void contractShowForBs(HttpServletRequest request, ModelMap modelMap) {
        String zsProjectIdStr = ParamUtils.getString(request, "zsProjectIdStr", "144");
        String azProjectIdStr = ParamUtils.getString(request, "azProjectIdStr", "19,20,21");
        List<ZsProject> zsProjectList = this.zsProjectService.getZsProjectListByZsProjectIdStr(zsProjectIdStr);
        List<AzProject> azProjectList = this.azProjectService.getAzProjectListByAzProjectIdStr(azProjectIdStr);

        Map<String, AzProject> azProjectMap = this.azProjectService.getAzProjectMap();

        modelMap.addAttribute("zsProjectIdStr", zsProjectIdStr);
        modelMap.addAttribute("azProjectIdStr", azProjectIdStr);
        modelMap.addAttribute("zsProjectList", zsProjectList);
        modelMap.addAttribute("azProjectList", azProjectList);
        modelMap.addAttribute("azProjectMap", azProjectMap);
    }

    /**
     * 选房家庭明细
     *
     * @param request
     * @return
     */
    @RequestMapping("getChooseHouseInfo")
    @ResponseBody
    public Map getChooseHouseInfo(HttpServletRequest request) {
        String zsProjectIdStr = ParamUtils.getString(request, "zsProjectIdStr", "");
        String azProjectIdStr = ParamUtils.getString(request, "azProjectIdStr", "");
        Integer pageSize = ParamUtils.getInt(request, "pageSize", 16);
        Integer pageNo = ParamUtils.getInt(request, "pageNo", 1);
        PageBean<Contract> pageBean = new PageBean<Contract>();
        pageBean = this.contractService.getChoosedHouseContractPageBean(zsProjectIdStr, azProjectIdStr, pageSize, pageNo);
        List<Map> dataLists = Lists.newLinkedList();
        Map<Integer, List<House>> houseMap = Maps.newHashMap();
        Map<Integer, List<CarLot>> carLotMap = Maps.newHashMap();
        Map<Integer, List<StorageRoom>> storageRoomMap = Maps.newHashMap();
        if (CollectionUtils.isNotEmpty(pageBean.getDatas())) {
            List<Integer> contractIdList = Lists.newArrayList();
            for (Contract contract : pageBean.getDatas()) {
                contractIdList.add(contract.getId());
            }
            houseMap = this.houseService.getHouseMapByContractIdList(contractIdList);
            carLotMap = this.carLotService.getCarLotMapByContractIdList(contractIdList);
            storageRoomMap = this.storageRoomService.getStorageRoomMapByContractIdList(contractIdList);
        }

        if (CollectionUtils.isNotEmpty(pageBean.getDatas())) {
            Map map = null;
            String strInfo;
            String houseStr;
            String carLotStr;
            String storageRoomStr;
            String syAreaStr;
            for (Contract contract : pageBean.getDatas()) {
                map = null;
                houseStr = "";
                carLotStr = "";
                storageRoomStr = "";
                syAreaStr = "";
                map = Maps.newHashMap();
                map.put("printTableName", StringUtils.getNotNull(contract.getZsProject().getPrintTableName()));
                map.put("name", StringUtils.getNotNull(contract.getName()));
                map.put("chooseHouseNum", StringUtils.getNotNull(contract.getChooseHouseNum()));
                BigDecimal syArea = new BigDecimal("0");
                if (contract.getIsJiSuan() == 2) {
                    syArea = this.contractService.getSyAreaByAzContractId(contract.getId());
                }
                if (CollectionUtils.isNotEmpty(houseMap.get(contract.getId()))) {
                    for (House house : houseMap.get(contract.getId())) {
                        houseStr += house.getAzProject().getMemo() + house.getHouseNumStr() + ",";
                    }
                }
                if (CollectionUtils.isNotEmpty(carLotMap.get(contract.getId()))) {
                    for (CarLot carLot : carLotMap.get(contract.getId())) {
                        carLotStr += carLot.getAzProject().getMemo() + carLot.getHouseNumStr() + ",";
                    }
                }
                if (CollectionUtils.isNotEmpty(storageRoomMap.get(contract.getId()))) {
                    for (StorageRoom storageRoom : storageRoomMap.get(contract.getId())) {
                        storageRoomStr += storageRoom.getHouseNumStr() + ",";
                    }
                }
                map.put("strInfo", houseStr + carLotStr + storageRoomStr);
                map.put("houseStrInfo", houseStr);
                map.put("carLotStrInfo", carLotStr);
                map.put("chooseHouseDate", DateUtils.dateToStringFormat(contract.getChooseHouseDate(), "yyyy-MM-dd HH:mm"));
                dataLists.add(map);
            }
        }
        Map resultMap = Maps.newHashMap();
        resultMap.put("totalCount", pageBean.getTotalCount());
        resultMap.put("dataLists", dataLists);

        Date nowDate = new Date();
        if (DateUtils.stringToDateTimeCompare(nowDate).equals("上午")) {
            resultMap.put("timeStr", DateUtils.dateToStringDefault(nowDate) + "上午已选房情况");
        } else if (DateUtils.stringToDateTimeCompare(nowDate).equals("下午")) {
            resultMap.put("timeStr", DateUtils.dateToStringDefault(nowDate) + "下午已选房情况");
        }
        return resultMap;
    }

    /**
     * 相应的征收项目下所分配的房源各楼统计
     *
     * @param request
     * @return
     */
    @RequestMapping("getBuildChooseHouseInfo")
    @ResponseBody
    public Map getBuildChooseHouseInfo(HttpServletRequest request) {
        String zsProjectIdStr = ParamUtils.getString(request, "zsProjectIdStr", "");
        String azProjectIdStr = ParamUtils.getString(request, "azProjectIdStr", "");
        Map<String, Map<String, Map<String, Integer>>> chooseHouseCountMap = this.houseService.getChooseHouseCountMap(zsProjectIdStr, azProjectIdStr);
        Map<String, AzProject> azProjectMap = this.azProjectService.getAzProjectMap();
        StringBuffer build = new StringBuffer("[");//楼号
        StringBuffer chooseCount = new StringBuffer("[");//已选
        StringBuffer noChooseCount = new StringBuffer("[");//未选
        StringBuffer pie = new StringBuffer("[");//饼图已选、未选
        StringBuffer chooseHouseInfo = new StringBuffer("[");//文字显示内容
        BigDecimal qifaArea, syqifangArea;

        if (CollectionUtils.isNotEmpty(chooseHouseCountMap)) {
            Map<String, Map<String, Integer>> itemMap = null;
            Map<String, Integer> itemItemMap = null;
            AzProject azProject = null;
            int houseTotalCount = 0, smallHouseTotalCount = 0, fsHouseTotalCount = 0,
                    normalHouseTotalCount = 0, noSmallHouseTotalCount = 0, noNormalHouseTotalCount = 0,
                    noFsHouseTotalCount = 0, total_choose = 0, total_noChoose = 0, total_chooseCur = 0,
                    bigHouseTotalCount = 0, total_big_choose = 0, total_big_noChoose = 0,
                    noBigHouseTotalCount = 0, total_noBig_choose = 0, total_noBig_noChoose = 0;
            for (String azProjectId : chooseHouseCountMap.keySet()) {
                azProject = null;
                itemMap = null;
                azProject = azProjectMap.get(azProjectId);
                itemMap = chooseHouseCountMap.get(azProjectId);
                if (CollectionUtils.isNotEmpty(itemMap)) {
                    for (String key : itemMap.keySet()) {
                        build.append("'" + key + "幢'").append(",");
                        itemItemMap = null;
                        itemItemMap = itemMap.get(key);

                        //总数量
                        int houseCount = Integer.valueOf(itemItemMap.get("houseCount"));
                        houseTotalCount = IntegerUtils.getSum(houseTotalCount, houseCount);
                        //剩余数量
                        int noChoose = Integer.valueOf(itemItemMap.get("noChooseCount"));
                        total_noChoose = IntegerUtils.getSum(total_noChoose, noChoose);
                        //今日选房数量
                        int choose_cur = Integer.valueOf(itemItemMap.get("chooseCountCur"));
                        total_chooseCur = IntegerUtils.getSum(total_chooseCur, choose_cur);
                        //累计已选数量
                        int choose = Integer.valueOf(itemItemMap.get("chooseCount"));
                        total_choose = IntegerUtils.getSum(total_choose, choose);
                        //小户型数量
                        int smallHouseCount = Integer.valueOf(itemItemMap.get("smallHouseCount"));
                        smallHouseTotalCount = IntegerUtils.getSum(smallHouseTotalCount, smallHouseCount);
                        //小户型剩余数量
                        int noSmallHouseCount = Integer.valueOf(itemItemMap.get("noSmallHouseCount"));
                        noSmallHouseTotalCount = IntegerUtils.getSum(noSmallHouseTotalCount, noSmallHouseCount);
                        //复式数量
                        int fsHouseCount = Integer.valueOf(itemItemMap.get("fsHouseCount"));
                        fsHouseTotalCount = IntegerUtils.getSum(fsHouseTotalCount, fsHouseCount);
                        //复式型剩余数量
                        int noFsHouseCount = Integer.valueOf(itemItemMap.get("noFsHouseCount"));
                        noFsHouseTotalCount = IntegerUtils.getSum(noFsHouseTotalCount, noFsHouseCount);
                        //普通型数量
                        int normalHouseCount = Integer.valueOf(itemItemMap.get("normalHouseCount"));
                        normalHouseTotalCount = IntegerUtils.getSum(normalHouseTotalCount, normalHouseCount);
                        //普通型剩余数量
                        int noNormalHouseCount = Integer.valueOf(itemItemMap.get("noNormalHouseCount"));
                        noNormalHouseTotalCount = IntegerUtils.getSum(noNormalHouseTotalCount, noNormalHouseCount);
                        //大户型总数量（复式、五房）
                        int bigHouseCount = Integer.valueOf(itemItemMap.get("bigHouseCount"));
                        bigHouseTotalCount = IntegerUtils.getSum(bigHouseTotalCount, bigHouseCount);
                        //大户型剩余总数量（复式、五房）
                        int bigHouseNoChooseCount = Integer.valueOf(itemItemMap.get("bigHouseNoChooseCount"));
                        total_big_noChoose = IntegerUtils.getSum(total_big_noChoose, bigHouseNoChooseCount);
                        //非大户型总数量（二房、三房、四房）
                        int noBigHouseCount = Integer.valueOf(itemItemMap.get("noBigHouseCount"));
                        noBigHouseTotalCount = IntegerUtils.getSum(noBigHouseTotalCount, noBigHouseCount);
                        //非大户型剩余数量（二房、三房、四房）
                        int noBigHouseNoChosoeCount = Integer.valueOf(itemItemMap.get("noBigHouseNoChosoeCount"));
                        total_noBig_noChoose = IntegerUtils.getSum(total_noBig_noChoose, noBigHouseNoChosoeCount);

                        chooseCount.append(choose).append(",");//已签约
                        noChooseCount.append(noChoose).append(",");//未签约
                    }
                }
            }
            build.deleteCharAt(build.lastIndexOf(","));
            chooseCount.deleteCharAt(chooseCount.lastIndexOf(","));
            noChooseCount.deleteCharAt(noChooseCount.lastIndexOf(","));
            pie.append(total_choose).append(",").append(total_noChoose);
            chooseHouseInfo.append(houseTotalCount).append(",").append(total_noChoose).append(",");
            chooseHouseInfo.append(total_chooseCur).append(",").append(total_choose).append(",");
            chooseHouseInfo.append(smallHouseTotalCount).append(",").append(noSmallHouseTotalCount).append(",");
            chooseHouseInfo.append(normalHouseTotalCount).append(",").append(noNormalHouseTotalCount).append(",");
            chooseHouseInfo.append(fsHouseTotalCount).append(",").append(noFsHouseTotalCount).append(",");
            chooseHouseInfo.append(bigHouseTotalCount).append(",").append(total_big_noChoose).append(",");
            chooseHouseInfo.append(noBigHouseTotalCount).append(",").append(total_noBig_noChoose);
        }
        build.append("]");
        chooseCount.append("]");
        noChooseCount.append("]");
        pie.append("]");
        chooseHouseInfo.append("]");

        Map map = Maps.newHashMap();
        map.put("build", JSON.parse(build.toString()));
        map.put("chooseCount", JSON.parse(chooseCount.toString()));
        map.put("noChooseCount", JSON.parse(noChooseCount.toString()));
        map.put("pie", JSON.parse(pie.toString()));
        map.put("chooseHouseInfo", JSON.parse(chooseHouseInfo.toString()));
        Date nowDate = new Date();
        if (DateUtils.stringToDateTimeCompare(nowDate).equals("上午")) {
            map.put("timeStr", DateUtils.dateToStringDefault(nowDate) + "上午已选房情况");
        } else if (DateUtils.stringToDateTimeCompare(nowDate).equals("下午")) {
            map.put("timeStr", DateUtils.dateToStringDefault(nowDate) + "下午已选房情况");
        }
        return map;
    }

    /**
     * 相应的征收项目下所分配的房源各楼统计
     *
     * @param request
     * @return
     */
    @RequestMapping("getBuildChooseHouseInfForBs")
    @ResponseBody
    public Map getBuildChooseHouseInfForBs(HttpServletRequest request) {
        String zsProjectIdStr = ParamUtils.getString(request, "zsProjectIdStr", "");
        String azProjectIdStr = ParamUtils.getString(request, "azProjectIdStr", "");
        String houseStyle = ParamUtils.getString(request, "houseStyle", "");
        Map<String, Map<String, Map<String, Integer>>> chooseHouseCountMap = this.houseService.getChooseHouseCountMapForBs(zsProjectIdStr, azProjectIdStr, houseStyle);
        Map<String, AzProject> azProjectMap = this.azProjectService.getAzProjectMap();
        StringBuffer build = new StringBuffer("[");//楼号
        StringBuffer chooseCount = new StringBuffer("[");//已选
        StringBuffer noChooseCount = new StringBuffer("[");//未选
        StringBuffer pie = new StringBuffer("[");//饼图已选、未选
        StringBuffer chooseHouseInfo = new StringBuffer("[");//文字显示内容
        BigDecimal qifaArea, syqifangArea;

        if (CollectionUtils.isNotEmpty(chooseHouseCountMap)) {
            Map<String, Map<String, Integer>> itemMap = null;
            Map<String, Integer> itemItemMap = null;
            AzProject azProject = null;
            int houseTotalCount = 0, smallHouseTotalCount = 0, fsHouseTotalCount = 0,
                    normalHouseTotalCount = 0, noSmallHouseTotalCount = 0, noNormalHouseTotalCount = 0,
                    noFsHouseTotalCount = 0, total_choose = 0, total_noChoose = 0, total_chooseCur = 0,
                    bigHouseTotalCount = 0, total_big_choose = 0, total_big_noChoose = 0,
                    noBigHouseTotalCount = 0, total_noBig_choose = 0, total_noBig_noChoose = 0;
            for (String azProjectId : chooseHouseCountMap.keySet()) {
                azProject = null;
                itemMap = null;
                azProject = azProjectMap.get(azProjectId);
                itemMap = chooseHouseCountMap.get(azProjectId);
                if (CollectionUtils.isNotEmpty(itemMap)) {
                    for (String key : itemMap.keySet()) {
                        build.append("'" + key + "幢'").append(",");
                        itemItemMap = null;
                        itemItemMap = itemMap.get(key);

                        //总数量
                        int houseCount = Integer.valueOf(itemItemMap.get("houseCount"));
                        houseTotalCount = IntegerUtils.getSum(houseTotalCount, houseCount);
                        //剩余数量
                        int noChoose = Integer.valueOf(itemItemMap.get("noChooseCount"));
                        total_noChoose = IntegerUtils.getSum(total_noChoose, noChoose);
                        //今日选房数量
                        int choose_cur = Integer.valueOf(itemItemMap.get("chooseCountCur"));
                        total_chooseCur = IntegerUtils.getSum(total_chooseCur, choose_cur);
                        //累计已选数量
                        int choose = Integer.valueOf(itemItemMap.get("chooseCount"));
                        total_choose = IntegerUtils.getSum(total_choose, choose);
                        //小户型数量
                        int smallHouseCount = Integer.valueOf(itemItemMap.get("smallHouseCount"));
                        smallHouseTotalCount = IntegerUtils.getSum(smallHouseTotalCount, smallHouseCount);
                        //小户型剩余数量
                        int noSmallHouseCount = Integer.valueOf(itemItemMap.get("noSmallHouseCount"));
                        noSmallHouseTotalCount = IntegerUtils.getSum(noSmallHouseTotalCount, noSmallHouseCount);
                        //复式数量
                        int fsHouseCount = Integer.valueOf(itemItemMap.get("fsHouseCount"));
                        fsHouseTotalCount = IntegerUtils.getSum(fsHouseTotalCount, fsHouseCount);
                        //复式型剩余数量
                        int noFsHouseCount = Integer.valueOf(itemItemMap.get("noFsHouseCount"));
                        noFsHouseTotalCount = IntegerUtils.getSum(noFsHouseTotalCount, noFsHouseCount);
                        //普通型数量
                        int normalHouseCount = Integer.valueOf(itemItemMap.get("normalHouseCount"));
                        normalHouseTotalCount = IntegerUtils.getSum(normalHouseTotalCount, normalHouseCount);
                        //普通型剩余数量
                        int noNormalHouseCount = Integer.valueOf(itemItemMap.get("noNormalHouseCount"));
                        noNormalHouseTotalCount = IntegerUtils.getSum(noNormalHouseTotalCount, noNormalHouseCount);
                        //大户型总数量（复式、五房）
                        int bigHouseCount = Integer.valueOf(itemItemMap.get("bigHouseCount"));
                        bigHouseTotalCount = IntegerUtils.getSum(bigHouseTotalCount, bigHouseCount);
                        //大户型剩余总数量（复式、五房）
                        int bigHouseNoChooseCount = Integer.valueOf(itemItemMap.get("bigHouseNoChooseCount"));
                        total_big_noChoose = IntegerUtils.getSum(total_big_noChoose, bigHouseNoChooseCount);
                        //非大户型总数量（二房、三房、四房）
                        int noBigHouseCount = Integer.valueOf(itemItemMap.get("noBigHouseCount"));
                        noBigHouseTotalCount = IntegerUtils.getSum(noBigHouseTotalCount, noBigHouseCount);
                        //非大户型剩余数量（二房、三房、四房）
                        int noBigHouseNoChosoeCount = Integer.valueOf(itemItemMap.get("noBigHouseNoChosoeCount"));
                        total_noBig_noChoose = IntegerUtils.getSum(total_noBig_noChoose, noBigHouseNoChosoeCount);

                        chooseCount.append(choose).append(",");//已签约
                        noChooseCount.append(noChoose).append(",");//未签约
                    }
                }
            }
            build.deleteCharAt(build.lastIndexOf(","));
            chooseCount.deleteCharAt(chooseCount.lastIndexOf(","));
            noChooseCount.deleteCharAt(noChooseCount.lastIndexOf(","));
            pie.append(total_choose).append(",").append(total_noChoose);
            chooseHouseInfo.append(houseTotalCount).append(",").append(total_noChoose).append(",");
            chooseHouseInfo.append(total_chooseCur).append(",").append(total_choose).append(",");
            chooseHouseInfo.append(smallHouseTotalCount).append(",").append(noSmallHouseTotalCount).append(",");
            chooseHouseInfo.append(normalHouseTotalCount).append(",").append(noNormalHouseTotalCount).append(",");
            chooseHouseInfo.append(fsHouseTotalCount).append(",").append(noFsHouseTotalCount).append(",");
            chooseHouseInfo.append(bigHouseTotalCount).append(",").append(total_big_noChoose).append(",");
            chooseHouseInfo.append(noBigHouseTotalCount).append(",").append(total_noBig_noChoose);
        }
        build.append("]");
        chooseCount.append("]");
        noChooseCount.append("]");
        pie.append("]");
        chooseHouseInfo.append("]");

        Map map = Maps.newHashMap();
        map.put("build", JSON.parse(build.toString()));
        map.put("chooseCount", JSON.parse(chooseCount.toString()));
        map.put("noChooseCount", JSON.parse(noChooseCount.toString()));
        map.put("pie", JSON.parse(pie.toString()));
        map.put("chooseHouseInfo", JSON.parse(chooseHouseInfo.toString()));
        Date nowDate = new Date();
        if (DateUtils.stringToDateTimeCompare(nowDate).equals("上午")) {
            map.put("timeStr", DateUtils.dateToStringDefault(nowDate) + "上午已选房情况");
        } else if (DateUtils.stringToDateTimeCompare(nowDate).equals("下午")) {
            map.put("timeStr", DateUtils.dateToStringDefault(nowDate) + "下午已选房情况");
        }
        return map;
    }

    /**
     * 楼盘销控展示
     */
    @RequestMapping("houseShowMain")
    public void houseShowMain(ModelMap modelMap) {
        this.contractShowMain(modelMap);
    }

    /**
     * 楼盘销控展示主界面
     */
    @RequestMapping("houseShow")
    public void houseShow(HttpServletRequest request, ModelMap modelMap) {
        String zsProjectIdStr = ParamUtils.getString(request, "zsProjectIdStr", "");
        String azProjectIdStr = ParamUtils.getString(request, "azProjectIdStr", "");
        List<String> azProjectIdBuildNumList = this.houseService.getAzProjectIdBuildNumList(zsProjectIdStr, azProjectIdStr);
        Map<String, AzProject> azProjectMap = this.azProjectService.getAzProjectMap();
        modelMap.addAttribute("zsProjectIdStr", zsProjectIdStr);
        modelMap.addAttribute("azProjectIdStr", azProjectIdStr);
        modelMap.addAttribute("azProjectMap", azProjectMap);
        modelMap.addAttribute("azProjectIdBuildNumList", azProjectIdBuildNumList);
    }

    /**
     * 楼盘销控展示主界面
     */
    @RequestMapping("houseShowForBs")
    public void houseShowForBs(HttpServletRequest request, ModelMap modelMap) {
        String zsProjectIdStr = ParamUtils.getString(request, "zsProjectIdStr", "144");
        String azProjectIdStr = ParamUtils.getString(request, "azProjectIdStr", "19,20,21");
        List<String> azProjectIdBuildNumList = this.houseService.getAzProjectIdBuildNumList(zsProjectIdStr, azProjectIdStr);
        Map<String, AzProject> azProjectMap = this.azProjectService.getAzProjectMap();
        modelMap.addAttribute("zsProjectIdStr", zsProjectIdStr);
        modelMap.addAttribute("azProjectIdStr", azProjectIdStr);
        modelMap.addAttribute("azProjectMap", azProjectMap);
        modelMap.addAttribute("azProjectIdBuildNumList", azProjectIdBuildNumList);
    }

    /**
     * 获取房源数据
     *
     * @param request
     * @return
     */
    @RequestMapping("houseHoldMapData")
    public void houseHoldMapData(HttpServletRequest request, ModelMap modelMap) {
        String zsProjectIdStr = ParamUtils.getString(request, "zsProjectIdStr", "");
        String azProjectIdStr = ParamUtils.getString(request, "azProjectIdStr", "");
        Map<String, Map<String, Map<String, Map>>> houseHoldDataMap = this.houseService.getHouseHoldMap(zsProjectIdStr, azProjectIdStr);
        Map<String, String> houseHoldMap = this.dataDictService.getMapByParentNameForValue_Name("房屋户型");
        Map<String, AzProject> azProjectMap = this.azProjectService.getAzProjectMap();
        modelMap.addAttribute("houseHoldDataMap", houseHoldDataMap);
        modelMap.addAttribute("houseHoldMap", houseHoldMap);
        modelMap.addAttribute("azProjectMap", azProjectMap);
    }

    /**
     * 获取房源数据
     *
     * @param request
     * @return
     */
    @RequestMapping("houseShowHoldForBs")
    public void houseShowHoldForBs(HttpServletRequest request, ModelMap modelMap) {
        String zsProjectIdStr = ParamUtils.getString(request, "zsProjectIdStr", "144");
        String azProjectIdStr = ParamUtils.getString(request, "azProjectIdStr", "19,20,21");
        Map<String, Map<String, Map>> houseHoldDataMap = this.houseService.getHouseHoldForBsMap(zsProjectIdStr, azProjectIdStr);
        Map<String, String> houseHoldMap = this.dataDictService.getMapByParentNameForValue_Name("房屋户型");
        Map<String, AzProject> azProjectMap = this.azProjectService.getAzProjectMap();
        modelMap.addAttribute("houseHoldDataMap", houseHoldDataMap);
        modelMap.addAttribute("houseHoldMap", houseHoldMap);
        modelMap.addAttribute("azProjectMap", azProjectMap);
    }

    /**
     * 楼盘图
     *
     * @param request
     */
    @RequestMapping("housePic")
    public void housePic(HttpServletRequest request, ModelMap modelMap) {
        String zsProjectIdStr = ParamUtils.getString(request, "zsProjectIdStr", "");
        Integer azProjectId = ParamUtils.getInt(request, "azProjectId", 0);
        String buildNum = ParamUtils.getString(request, "buildNum", "");
        //通过征收项目、安置项目、楼号得到所分配的houseList
        List<House> houseList = houseService.houseList(zsProjectIdStr, azProjectId, buildNum);
        //得到层号和当前楼层的List<House>对应的map
        Map<String, List<House>> floorHouseMap = houseService.getFloorHouseMap(houseList);
        //获取当前安置项目最高层
        Map<String, Integer> maxFloorMap = houseService.getMaxFloorMap(zsProjectIdStr, azProjectId, buildNum);
        Integer maxFloor = maxFloorMap.get("maxFloor");
        //房源状态
        Map<String, String> colorMap = this.dataDictService.getMapByParentNameForValue_Color("房源状态");
        //房屋类型
        Map<String, String> houseHoldMap = this.dataDictService.getMapByParentNameForValue_Name("房屋户型");

        modelMap.addAttribute("buildNum", buildNum);
        modelMap.addAttribute("floorHouseMap", floorHouseMap);
        modelMap.addAttribute("maxFloor", maxFloor);
        modelMap.addAttribute("colorMap", colorMap);
        modelMap.addAttribute("houseHoldMap", houseHoldMap);
    }
}
